package rf.vir

import grails.validation.Validateable;

@Validateable
class ProfileChangeCommand {
	User user
	String oldPassword
	String newPassword
	String confirmNewPassword
	
	static constraints = {
		newPassword blank:false, validator:{ val, obj ->
			if(val != obj.confirmNewPassword) {
				"global.passwordsNotEqual"
			}
		}
		
		oldPassword blank:false, validator: { val, obj ->
			if(obj.user) {
				if(val != obj.user.password) {
					"global.passwordInvalid"
				}
			}
		}
	}
}
